
package reittiopas;


import java.util.Date;
import java.util.Vector;

/**
 *
 * @author Jaakko, Petteri
 */
public class Controller {
	
	private IRouteService routeService;
	private ITimeFormatter timeFormatter;
	
	public Controller(IRouteService service, ITimeFormatter formatter) {
		
		routeService = service;
		timeFormatter = formatter;
		
		
	}
	
	
	public Vector getRoutes(String startAddress, String destAddress, String time, String date,  boolean isStartTime) {
		
		if(startAddress.length() == 0 || destAddress.length() == 0) {
			return null;
		}
		
		Vector routes = null;
		Location startLocation = routeService.getLocation(startAddress);
    	Location destinationLocation = routeService.getLocation(destAddress);
    	
    	if (startLocation==null || destinationLocation == null)
    		return null;
    	
    	time = timeFormatter.trimTimeString(time);
    	
    	routes = routeService.getRoutes(startLocation, destinationLocation, time, date, isStartTime); 
        //Route routeWithStreetnames = routeService.getStreetNamesToSubRoutes((Route)routes.firstElement());
		return routes;
	}
	
	
	
	

}
